<template>
  <div class="dashboard-container">
    <div class="app-container">
      <el-card class="tree-card">
        <!-- 用了一个行列布局 -->
        <el-row
          type="flex"
          justify="space-between"
          align="middle"
          style="height: 40px"
        >
          <el-col>
            <strong><i
              class="el-icon-s-home"
            />江苏传智播客教育科技股份有限公司</strong>
          </el-col>
          <el-col :span="4">
            <el-row type="flex" justify="end">
              <!-- 两个内容 -->
              <el-col>负责人</el-col>
              <el-col>
                <!-- 下拉菜单 element -->
                <el-dropdown>
                  <span> 操作<i class="el-icon-arrow-down" /> </span>
                  <!-- 下拉菜单 -->
                  <el-dropdown-menu slot="dropdown">
                    <el-dropdown-item>添加子部门</el-dropdown-item>
                  </el-dropdown-menu>
                </el-dropdown>
              </el-col>
            </el-row>
          </el-col>
        </el-row>
        <hr>
        <!-- 下面是树形组件显示不同的部门 -->
        <el-tree
          :data="departs"
          :default-expand-all="true"
        >
          <!-- 这里可以在开闭标签之间写入每一行应该显示的内容
            这里写的只是一行的模板，树形组件会自动遍历渲染 -->
          <!-- 这里是作用域插槽的写法
          一个用两个数据, 1. 插槽名, 2, 字段形参 -->
          <!-- 旧版(vue < 2.6.0) -->
          <!-- <template slot="default" slot-scope="scope"> -->
          <!-- 新版 (vue>2.6.0) -->
          <!-- <template v-slot:default="scope"> -->
          <template #default="scope">
            <!-- 这里包裹的内容, 跟上面公司信息行一模一样,也就是说
            每个部门渲染出来, 都跟一个公司数据结构是一样 -->
            <el-row
              type="flex"
              justify="space-between"
              align="middle"
              style="height: 40px;  width: 100%;"
            >
              <el-col>
                <strong><i
                  class="el-icon-s-home"
                />{{ scope.data.name }}</strong>
              </el-col>
              <el-col :span="4">
                <el-row type="flex" justify="end">
                  <!-- 两个内容 -->
                  <el-col>{{ scope.data.manager }}</el-col>
                  <el-col>
                    <!-- 下拉菜单 element -->
                    <el-dropdown>
                      <span> 操作<i class="el-icon-arrow-down" /> </span>
                      <!-- 下拉菜单 -->
                      <el-dropdown-menu slot="dropdown">
                        <el-dropdown-item>添加子部门</el-dropdown-item>
                      </el-dropdown-menu>
                    </el-dropdown>
                  </el-col>
                </el-row>
              </el-col>
            </el-row>
          </template>
        </el-tree></el-card>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      departs: [
        {
          name: '总裁办',
          manager: '曹操',
          children: [
            { name: '董事会', manager: '曹丕' }
          ]
        },
        {
          name: '行政部',
          manager: '刘备' },
        {
          name: '人事部',
          manager: '孙权' }]
    }
  }
}
</script>

<style scoped>
.tree-card {
  padding: 30px 140px;
  font-size: 14px;

}
</style>
